import java.util.Random;
import java.util.Scanner;

class GameBean{
    GameBean(int a){
        Random random = new Random();
        int arr[] = new int[a];
        for (int i=0;i<a;i++){
            arr[i] = random.nextInt(3)+1;
        }
        setGame(arr);
    }
    private int[] game;
    //游戏规则
    //1.石头 2.剪刀 3.布
    //1+1=2<3 石头 布 返回大值为赢家
    //2+1=3=3 剪刀 布 返回小值为赢家
    //1+1=2=2 石头 剪刀 返回小值为赢家
    public int compare(int bean,int sc){
        if (bean == sc){
            return 0;
        }
        if (bean>sc && bean==sc+1 || bean<sc && bean+1<sc){
            return 1;
        }
        if (bean<sc && bean+1 == sc || bean>sc && bean>sc+1){
            return 2;
        }
        return 4;
    }

    public int[] getGame() {
        return game;
    }

    public void setGame(int[] game) {
        this.game = game;
    }
}

public class GameImp {
    public void start() {
        System.out.println("输入剪刀石头布游戏次数");
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        GameBean gameBean = new GameBean(k);
        System.out.println("进行游戏次数："+k);
        System.out.println("开始游戏：1.石头 2.剪刀 3.布");
        System.out.println("请输入你要出示的手势");
        int playWin =0;
        int draw =0;
        int lose =0;
//        for (int i = 0;i<gameBean.getGame().length;i++){
//            System.out.print(gameBean.getGame()[i]);
//        }
        System.out.println();
        for (int i = 0;i<5;i++){
            int lo = scanner.nextInt();
            int bo = gameBean.compare(gameBean.getGame()[i],lo);
            if (bo ==0){
                draw++;
                System.out.println("单局平局");
            }
            if (bo ==1){
                playWin++;
                System.out.println("单局获胜");
            }
            if (bo ==2){
                lose++;
                System.out.println("单局获败");
            }

        }
        if (playWin > k/2){
            System.out.println("获得总胜利:胜利次数"+playWin+"失败次数："+lose+"平局次数:"+draw);
        }
        else if (draw == k){
            System.out.println("平局");
        }
        else {
            System.out.println("失败------胜利次数"+playWin+"失败次数："+lose+"平局次数:"+draw);
        }
    }
    public static class ThreadExtends extends Thread{
        public ThreadExtends(){
            super();
        }
        @Override
        public void run() {
            GameImp gameImp = new GameImp();
            gameImp.start();
        }
    }

    public static void main(String[] args) {
        ThreadExtends threadExtends = new ThreadExtends();
        System.out.println("开启线程...");
        threadExtends.start();
    }
}
